package portal.cmd.beans;

public class JhostBean {
	String hostName;
	String[] hostData=null;
	String[] hostStat=null;
	public JhostBean(){};
	public JhostBean(String hname,String[]data){
		hostName=hname;
		hostData=data;
	}
	public JhostBean(String hname,String[]data,String []stat){
		hostName=hname;
		hostData=data;
		hostStat=stat;
	}
	public String getHostName() {
		return hostName;
	}
	public String[] getHostData() {
		return hostData;
	}
	public void setHostName(String hostName) {
		this.hostName = hostName;
	}
	public void setHostData(String[] hostData) {
		this.hostData = hostData;
	}
	
	public String[] getHostStat() {
		return hostStat;
	}
	public void setHostStat(String[] hostStat) {
		this.hostStat = hostStat;
	}
	public String getStatus(){
		return getAt(1);
	}
	public int getJLperU(){
		return getAsIntAt(2);
	}
	public int getMAX(){
		return getAsIntAt(3);
	}
	public int getNJOBS(){
		return getAsIntAt(4);
	}
	public int getRUN(){
		return getAsIntAt(5);
	}
	public int getSSUSP(){
		return getAsIntAt(6);
	}
	public int getUSUSP(){
		return getAsIntAt(7);
	}
	public int getRSV(){
		return getAsIntAt(8);
	}
	public String getGPU(){
		return getAt(9);
	}
	public int getAsIntAt(int i){
		String val=getAt(i);
		if(val==null)return 0;
		return Integer.valueOf(val);
	}
	/*****
	 * 直接索引起始位置1 、2、3...，
	 * ****/
	public String getAt(int i){
		if(i<=1)
			i=1;
		if(isOverflow(i))
			return null;
		if("-".equals(hostData[i-1]))
			return null;

		return hostData[i-1];
	}
	public boolean isOverflow(int i){
		if(hostData==null)
			return true;
		if(hostData.length<i)
			return true;
		return false;
	}
}
